package response;

import core.Constants;
import core.GamePacket;
import core.Message;
import java.util.Vector;

/**
 *
 * @author brian
 */
public class ResponseUpdateChatPrivate extends GameResponse {

    private Vector<Message> messages;

    public void setMessages(Vector<Message> m) {
        this.messages = m;
    }
    public ResponseUpdateChatPrivate() {
        code = Constants.SMSG_SEND_PRIVATE_CHAT;
    }

    @Override
    public byte[] createResponse() {
        GamePacket packet = new GamePacket(code);
        /*Protocol:
        * (int) numResults, [(String) charName, (String) message]*
        */
        if(messages == null)
            messages = new Vector<Message>();
        packet.addUint32(messages.size());
        for(Message message : messages) {
            packet.addString(message.getSender());
            packet.addString(message.getText());
        }

        return packet.getBytes();
    }
}
